<template>
	<view class="content" style="display: flex;align-content: center;">
		<view class="page-section page-section-gap">
			<map style="width: 100%; height: 100%;" :latitude="latitude" :longitude="longitude" :markers="covers">
				<cover-view class="controls-title" @click="play">查看详情</cover-view> 
			</map>
			
		</view>
		
 
	</view>
</template>

<script>
export default {
	data() {
		return {
			latitude: 34.29318,
			longitude: 108.94712,
			covers: [],
			now_page: 1,
			distance_sort: 0, //距离排序 1、倒序 2、正序 0 、综合(筛选时好评筛选字段赋值为0或者空)
			comment_score_sort: 0 //好评排序 1、倒序 2、正序 0、综合(筛选时排序筛选字段赋值为0或者空)
		};
	},
	methods: {
		//查看更多
		play: function() {
			uni.navigateTo({
				url: '../lookindex/lookindex'
			});
		},
		// 获取地图 当前位置周边 维修点
		get_shop_list: async function() {
			let data = {
				latitude: this.latitude,
				longitude: this.latitude
			};
			let list = (await this.$ajax.post({ url: '/Shop/shopList', data })).data;
			list.forEach(item=>{
				this.covers.push({
					latitude: item.latitude,
					longitude: item.longitude,
					iconPath: "/static/images/ads.png"
				});
			});
			 
		},
		// 初始化
		index_init() {
			let that = this;
			uni.getLocation({
				type: 'wgs84',
				success: res => {
					console.log(res);
					that.latitude = res.latitude;
					that.longitude = res.longitude;
					that.covers.push({
						latitude: res.latitude,
						longitude: res.longitude,
						iconPath: '../../../static/images/location.png'
					});
					this.get_shop_list();
				},
				fail(res) {
					console.log(res);
				}
			});
		}
	},
	onLoad() {
		this.index_init();
	}
};
</script>

<style>
.content {
	flex: 1;
	justify-content: center;
	align-items: center;
	position: relative;
}
.page-section {
	height: 100vh;
	width: 100%;
}
.controls-title {
	position: absolute;
	bottom: 50upx;
	background: #5a71fb;
	color: #fff;
	border-radius: 50upx;
	width: 300upx;
	line-height: 80upx;
	height: 80upx;
	text-align: center;
	font-size: 34upx;
	font-family: Adobe 黑体 Std R;
	left: 220upx;
}
</style>
